function putTeam()
{
    $('#user_name').attr("disabled",false);
    $('#user_pass').attr("disabled",false);
    var userPass=$('#user_pass');
    var userPassConfirm=$('#user_pass_confirm');
    if(userPass.val().length != 32)
    {
        var md5pass=md5(userPass.val())
        userPass.val(md5pass);
    }
    userPassConfirm.val(md5(userPassConfirm.val()));
    if(userPass.val()==userPassConfirm.val())
    {
        $.ajaxSetup({async:false});
	putFact('rpp','team_members','');
	$("input[name='factTable']").remove();
	putFact('rpp','user_roles','teams.html');
	$.ajaxSetup({async:true});
    }
    else
    {
        alert("Passwords do not match.");
    }
}
$(function(){ 
    
	// Hide delete button if this is an insert rather than a delete
    if(isNull(getParameterByName('id')) || (getCookie('username') != 'admin'))
    {
        $('#deleteTeamButton').hide()
    }
    if(isNull(getParameterByName('id'))==false)
    {
	$('#user_name').textinput('disable');
        //$('#user_pass').textinput('disable');
        
        $('label[for=user_pass], input#user_pass').hide();
        $('label[for=user_pass_confirm], input#user_pass_confirm').hide();
    }
    // Remove Old password if updating team member
    getFieldSelection('rpp','team_members',null,function(){
        if(isNull(getParameterByName('id')) == false)
        {
                        
			$('#user_pass').val('');
                        $('#user_pass_confirm').val('');
        }
    });
});

function removeTeam()
{
    var result = confirm("Delete team member?");
    if(result == true)
    {
        executeQuery('rpp','deactivateTeamMember', 'id='+getParameterByName('id'),
            function(data)
            {
                window.location="teams.html";
            }
        );
    }
}

function changePassword()
{
    $('label[for=user_pass], input#user_pass').show();
    $('label[for=user_pass_confirm], input#user_pass_confirm').show();
    $('#user_pass').val('');
}

function userSpecifics()
{
     //removeTabs();
     var username = getCookie('username');
     if(username != "admin")
	{
	$('#mainData tbody tr').unbind('click');
	var createButton = $('.createButton');
	$('.createButton .ui-btn-text').text('Edit Profile');
	createButton.attr('href','teamMember.html?id='+getCookie('userid'));
	}
}
